home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_03_05
/
3n05066b
< prev
next >
Wrap
Text File
|
1992-02-22
|
2KB
|
36 lines
/*=========================== my_timer.c ==================================*/
/* A test program using "my_timer.h" to time the performance difference */
/* between using the function-like macro isdigit() or the corresponding */
/* runtime library function isdigit(); if the preprocessor object-like */
/* macro MY_TIMER is defined, the START and STOP macros are invoked; */
/* otherwise, no such code is generated, and no runtime performance */
/* penalty is imposed - much like using assertions - NDEBUG and assert(); */
/* */
/* Inspect the intermediate file (*.i) generated by the preprocessor to */
/* see the effects of using the START() and STOP macros; use compiler */
/* option -P for Microsoft C; run the CPP.EXE utility Borland C; */
/* */
/* NOTE: Remember to #define MY_TIMER (-DMY_TIMER on the command-line) */
/* before you #include "my_timer.h" */
/*=========================================================================*/
#include <ctype.h>
#define MY_TIMER /* This activates the timer code */
#include "my_timer.h"
void main( void) {
char ch = '9';
int i, is;
START(default function-like macro timing);
for (i=0; i<NTIMES; i++) is = isdigit(ch);
STOP;
#undef isdigit
START(alternate function timing);
for (i=0; i<NTIMES; i++) is = isdigit(ch);
STOP;
}
/*=========================== my_timer.c ==================================*/